package kolekcje.eng;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

public class Jukebox {
	
	ArrayList<String> songList = new ArrayList<String>();
	File file = JukeboxListSetter.plik;

	public void go(){
		getSongs();
		System.out.println();
		Collections.sort(songList);
		System.out.println(songList);
		System.out.println();
		for(String e : songList)
			System.out.println(e);
	}

	private void getSongs() {
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = null;
			while((line = br.readLine()) != null)
				addSong(line);
			br.close();
		} catch (FileNotFoundException e) {
			System.out.println("Nie odnaleziono pliku");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private void addSong(String lineToParse) {
		String[] tokens = lineToParse.split("/");
		songList.add(tokens[0]);
		System.out.println("Dodano: " + tokens[0] + ", odrzucono: " + tokens[1]);
	}
}
